package com.jarveis.dbs.core.filter;

import org.apache.log4j.Logger;

import com.jarveis.frame.redis.RedisManager;
import com.jarveis.frame.util.Param;

/**
 * @desc redis过滤器
 * @author liuguojun
 * @create 2016-01-12
 */
public class RedisFilter implements Filter {

	private Logger logger = Logger.getLogger(RedisFilter.class);

	public int init() {
		RedisManager.init();
		logger.info("初始化redis成功");
		return 0;
	}

	public int filter(Param param) {
		try {
			String tagName = param.getTagName();
			if (Param.RESP.equals(tagName)) {
				RedisManager.closeConnection();
				logger.info("断开redis连接");
			}
		} catch (Exception ex) {
			logger.error(ex.getMessage(), ex);
		}

		return 0;
	}

	public int destory() {

		return 0;
	}
}
